package it.tplmatera;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;

public class ShowLineaActivity extends ListActivity {
	
	ArrayAdapter<String> arrayAdapterFermate;
	List<String> arrayFermate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_show_linea);
		savedInstanceState = getIntent().getExtras();
		
		int a = getIdFermateDaVisualizzare(savedInstanceState);

		arrayFermate = new ArrayList<String>(Arrays.asList(getResources().getStringArray(a)));
		arrayAdapterFermate = new ArrayAdapter<String>(this, R.layout.item, arrayFermate);
		setListAdapter(arrayAdapterFermate);
		System.out.println("linea: "+savedInstanceState.getInt("keyLinea"));
		Log.i("ciao", "sei sulla linea "+savedInstanceState.getInt("keyLinea"));
		
	}
	
	private int getIdFermateDaVisualizzare(Bundle savedInstanceState) {
		switch(savedInstanceState.getInt("keyLinea")){
		case(0):
			return R.array.fermate_linea_uno;
		case(1):
			return R.array.fermate_linea_due;
		default:
			return 0;
		}
	}

	public void showFermata(View v){
		System.out.println("R.layout.item: "+R.layout.item);
		System.out.println("R.id: "+R.id.button_item);
		System.out.println("id Fermata: "+v.getId());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.show_linea, menu);
		return true;
	}

}
